import type { DataTableProps } from "naive-ui";
import { NAvatar, NImage, NTag } from "naive-ui";
import { h } from "vue";
import RenderGender from "@/components/RenderGender.vue";
import { formatTime, renderMaybeNull } from "@/utils";
import { AUTH_TYPE_MAP, USER_AUTH_STATUS_MAP, USER_AUTH_STATUS_MAP_COLOR } from '@/const/user'

const statusMap: Record<number, { text: string; type: 'success' | 'error' | 'warning' | 'info' }> = {
    10: { text: '已报名', type: 'info' },
    20: { text: '已绑卡', type: 'warning' },
    30: { text: '已签署', type: 'success' },
    40: { text: '已授权', type: 'success' }
};

export const productApplyColumns: DataTableProps["columns"] = [
	{
		title: '商品标题',
		key: 'productName',
		width: 180
	},
    {
        title: '商品编号',
        key: 'productNo',
        width: 180
    },
    {
        title: '商品价格',
        key: 'price',
        width: 120
    },
    {
        title: '用户名称',
        key: 'username',
        width: 120
    },
    {
        title: '用户编号',
        key: 'userNo',
        width: 120
    },
    {
        title: '手机号',
        key: 'phone',
        width: 120
    },

    {
        title: '状态',
        key: 'status',
        width: 100,
        render: (row: any) => {
            const statusInfo = statusMap[row.status] || { text: '未知', type: 'error' };
            return h(NTag, {
                type: statusInfo.type,
                round: true,
                size: 'small'
            }, { default: () => statusInfo.text });
        }
    },
	{
		title: '创建时间',
		key: 'createTime',
		width: 180,
		render: (row: any) => row.createTime ? formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss') : '-'
	},
    {
        title: '重要等级',
        key: 'importantLevel',
        width: 120,
        render: (row: any) => {
            const level = Number(row.importantLevel) || 0;
            return '⭐'.repeat(level);
        }
    },
    {
        title: '备注信息',
        key: 'remark',
        width: 180
    },
]

